<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改文件资源库')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-repository-edit" th:object="${ktRepository}">
            <input name="repositoryId" th:field="*{repositoryId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库名称：</label>
                <div class="col-sm-8">
                    <input name="repositoryName" th:field="*{repositoryName}" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库路径：</label>
                <div class="col-sm-8">
                    <input name="repositoryLocation" th:field="*{repositoryLocation}" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">仓库描述：</label>
                <div class="col-sm-8">
                    <input name="repositoryDescription" th:field="*{repositoryDescription}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">git地址：</label>
                <div class="col-sm-8">
                    <input name="gitUri" th:field="*{gitUri}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">SSH KEY</label>
                <div class="col-sm-8">
                    <textarea id="gitSshKey" name="gitSshKey" class="form-control" rows="3" th:field="*{gitSshKey}" required></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">git用户名：</label>
                <div class="col-sm-8">
                    <input name="gitUsername" id="gitUsername" th:field="*{gitUsername}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">git密码：</label>
                <div class="col-sm-8">
                    <input name="gitPassword" id="gitPassword" th:field="*{gitPassword}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
            <input type="hidden" name="gitAuthType" id="gitAuthType" th:field="*{gitAuthType}">
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "watchdog/repository";
        $("#form-repository-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-repository-edit').serialize());
            }
        }

        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='updatedTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            var authType = $("#gitAuthType").val();
            if (authType === "S") {
                $("#gitUsername").parents(".form-group").hide();
                $("#gitPassword").parents(".form-group").hide();
                $("#gitSshKey").parents(".form-group").show();
            } else {
                $("#gitSshKey").parents(".form-group").hide();
                $("#gitUsername").parents(".form-group").show();
                $("#gitPassword").parents(".form-group").show();
            }
        });
    </script>
</body>
</html>